home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Misc / bgui / Examples / Source / List.c < prev    next >
C/C++ Source or Header  |  2000-05-09  |  4KB  |  196 lines

  1. /*
  2.  * @(#) $Header: /cvsroot/bgui/examples/List.c,v 41.11 2000/05/09 20:33:43 mlemos Exp $
  3.  *
  4.  * List.c
  5.  *
  6.  * (C) Copyright 1998 Manuel Lemos.
  7.  * (C) Copyright 1995-1996 Jaba Development.
  8.  * (C) Copyright 1995-1996 Jan van den Baard.
  9.  * All Rights Reserved.
  10.  *
  11.  * This example will show the most simple form of
  12.  * a DragNDrop Listview. It opens a window with a
  13.  * single-select Listview object.
  14.  *
  15.  * The entries in the Listview can be moved in the
  16.  * list.
  17.  *
  18.  * $Log: List.c,v $
  19.  * Revision 41.11  2000/05/09 20:33:43  mlemos
  20.  * Bumped to revision 41.11
  21.  *
  22.  * Revision 1.2  2000/05/09 19:59:00  mlemos
  23.  * Merged with the branch Manuel_Lemos_fixes.
  24.  *
  25.  * Revision 1.1.2.1  1998/02/28 17:45:26  mlemos
  26.  * Ian sources
  27.  *
  28.  *
  29.  */
  30.  
  31. /* Execute me to compile with DICE V3.0
  32. dcc List.c -proto -mi -ms -mRR -lbgui
  33. quit
  34. */
  35.  
  36.  
  37. #include "DemoCode.h"
  38.  
  39. /*
  40.  *    Just a bunch of entries...
  41.  */
  42. STATIC UBYTE *entries[] = {
  43.     "Entry 1",
  44.     "Entry 2",
  45.     "Entry 3",
  46.     "Entry 4",
  47.     "Entry 5",
  48.     "Entry 6",
  49.     "Entry 7",
  50.     "Entry 8",
  51.     "Entry 9",
  52.     "Entry 10",
  53.     "Entry 11",
  54.     "Entry 12",
  55.     "Entry 13",
  56.     "Entry 14",
  57.     "Entry 15",
  58.     "Entry 16",
  59.     "Entry 17",
  60.     "Entry 18",
  61.     "Entry 19",
  62.     "Entry 20",
  63.     NULL
  64. };
  65.  
  66. /*
  67.  *    Object ID's
  68.  */
  69. #define ID_QUIT         1
  70.  
  71. static char *TabLabels[] =
  72. {
  73.     "Single-Select",
  74.     "Multi-Select",
  75.     NULL
  76. };
  77. /*
  78. **    Cycle to Page map-list.
  79. **/
  80. static ULONG Cyc2Page[] = { MX_Active, PAGE_Active, TAG_END };
  81.  
  82. /*
  83.  *    Here we go...
  84.  */
  85. VOID StartDemo( void )
  86. {
  87.     struct Window            *window;
  88.     Object            *WO_Window, *tabs, *page;
  89.     ULONG                 signal, rc;
  90.     BOOL                 running = TRUE;
  91.  
  92.     /*
  93.      *    Build the window object tree.
  94.      */
  95.     WO_Window = WindowObject,
  96.         WINDOW_Title,        "Listview DragNDrop",
  97.         WINDOW_ScaleWidth,    25,
  98.         WINDOW_ScaleHeight,    20,
  99.         WINDOW_RMBTrap,        TRUE,
  100.         WINDOW_AutoAspect,    TRUE,
  101.         WINDOW_AutoKeyLabel,    TRUE,
  102.         WINDOW_MasterGroup,
  103.             VGroupObject, NormalVOffset, NormalSpacing,
  104.                 StartMember,
  105.                     tabs = Tabs(NULL, TabLabels, 0, 0),
  106.                 EndMember,
  107.                 StartMember,
  108.                     page = PageObject,
  109.                     PageMember,
  110.                         VGroupObject, NormalHOffset, NormalSpacing,
  111.                             StartMember,
  112.                                 InfoFixed(NULL, ISEQ_C "Single-Select Drag-n-Drop\nListview object.", NULL, 2 ), FixMinHeight,
  113.                             EndMember,
  114.                             StartMember,
  115.                             /*
  116.                              *    Create a draggable and droppable listview
  117.                              *    and make it show the drop-spot.
  118.                              */
  119.                                 ListviewObject,
  120.                                     LISTV_EntryArray,        entries,
  121.                                     LISTV_ShowDropSpot,    TRUE,
  122.                                     BT_DragObject,            TRUE,
  123.                                     BT_DropObject,            TRUE,
  124.                                 EndObject,
  125.                             EndMember,
  126.                         EndObject,
  127.                     PageMember,
  128.                         VGroupObject, NormalHOffset, NormalSpacing,
  129.                             StartMember,
  130.                                 InfoFixed( NULL, ISEQ_C "Multi-Select Drag-n-Drop\nListview object.", NULL, 2 ), FixMinHeight,
  131.                             EndMember,
  132.                             StartMember,
  133.                             /*
  134.                              *    Create a multi-select, draggable and
  135.                              *    droppable listview and make it show
  136.                              *    the drop-spot.
  137.                              */
  138.                                 ListviewObject,
  139.                                     LISTV_MultiSelect,    TRUE,
  140.                                     LISTV_EntryArray,        entries,
  141.                                     LISTV_ShowDropSpot,    TRUE,
  142.                                     BT_DragObject,            TRUE,
  143.                                     BT_DropObject,            TRUE,
  144.                                 EndObject,
  145.                             EndMember,
  146.                         EndObject,
  147.                     EndObject,
  148.                 EndMember,
  149.                 StartMember,
  150.                     HGroupObject,
  151.                         VarSpace( DEFAULT_WEIGHT ),
  152.                         StartMember, FuzzButton( "_Quit", ID_QUIT ), EndMember,
  153.                         VarSpace( DEFAULT_WEIGHT ),
  154.                     EndObject, FixMinHeight,
  155.                 EndMember,
  156.             EndObject,
  157.     EndObject;
  158.  
  159.     /*
  160.      *    Window object tree OK?
  161.      */
  162.     if ( WO_Window ) {
  163.         /*
  164.         **    Connect the cycle to the page.
  165.         **/
  166.         AddMap(tabs, page, Cyc2Page );
  167.         /*
  168.          *    Open the window.
  169.          */
  170.         if ( window = WindowOpen( WO_Window )) {
  171.             /*
  172.              *    Get signal wait mask.
  173.              */
  174.             GetAttr( WINDOW_SigMask, WO_Window, &signal );
  175.  
  176.             do {
  177.                 Wait( signal );
  178.                     /*
  179.                  *    Handle messages.
  180.                  */
  181.                 while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
  182.                     switch ( rc ) {
  183.                         case    WMHI_CLOSEWINDOW:
  184.                         case    ID_QUIT:
  185.                             running = FALSE;
  186.                             break;
  187.                     }
  188.                 }
  189.             } while ( running );
  190.         } else
  191.             Tell( "Unable to open the window.\n" );
  192.         DisposeObject( WO_Window );
  193.     } else
  194.         Tell( "Unable to create the window object.\n" );
  195. }
  196.